home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / comm / mail / YamNet.lha / rexxtra12.lha / rexx / ListEnv.rexx < prev    next >
OS/2 REXX Batch file  |  1990-03-18  |  1KB  |  52 lines

  1. /* ListEnv.rexx */
  2.  
  3. /*
  4.      Format
  5.  
  6.        ListEnv [var]
  7.  
  8.    List all or a specific ENV variable.
  9.  
  10. */
  11. call addlib 'rexxextra.library',-20,-30,0
  12.  
  13. facility = 'ListEnv'
  14. retcode = 0
  15. template = 'VAR'
  16. dtemplate = template
  17. args. = ''
  18.  
  19. parse arg g_c
  20. do while g_c='?'
  21.   options prompt dtemplate': '  /* this template is      */
  22.   parse pull g_c        /* displayed to the user */
  23.   if g_c='?' then do
  24.     g_s=sourceline(3)
  25.     if pos('/*',g_s)=0 then break; if pos('*/',g_s)>0 then break
  26.     say
  27.     g_s=sourceline(4)
  28.     do i=5 while pos('*/',g_s)=0; say g_s; g_s=sourceline(i); end
  29.     say
  30.     end
  31.   end
  32. interpret Cparse(g_c,template,'args')
  33. if args.ERRCODE > 1 then do; say facility'-E-BADARGS,' args.ERRTEXT; exit 5; end
  34.  
  35. var = args.VAR
  36. width = (screencols()-30)%8
  37. namewidth = 20
  38. trailer = '1B'x || '[0m'
  39.  
  40. lines = sortwords(showdir('ENV:','F'))
  41. do i = 1 to words(lines)
  42.   line = word(lines,i)
  43.   if var = '' | abbrev(upper(line),var,1) then do
  44.     v = compress(getenv(line),'0A'x)
  45.     if length(v) > width-namewidth-1 then
  46.       v = substr(v,1,width-namewidth-4) || '...'
  47.     say left(line,namewidth) v || trailer
  48.     end
  49.   end
  50. exit retcode
  51.  
  52.